package com.tc.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * @Auther: tianchao
 * @Date: 2021/12/9 21:17
 * @Description:
 */
@RestController
public class TestController {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @GetMapping("test")
    public Callable<String> test(){
        logger.info("主线程开始");
        Callable<String>  result = new Callable<String>() {
            @Override
            public String call() throws Exception {
                logger.info("副线程开始");
                Thread.sleep(1000);
                logger.info("副线程结束");
                return "success";
            }
        };
        logger.info("主线程结束");
        return result;
    }
}
